package com.xq.ms;

import redis.clients.jedis.Jedis;

/**
 * @author xq
 * @version 1.0
 * @date 2021/4/28 12:38
 * @description 测试redis的主从复制
 */
public class TestRedisM_S {
    public static void main(String[] args) {
        // 创建主和从连接
        Jedis jedisM = new Jedis("192.168.2.120", 6381);
        Jedis jedisS = new Jedis("192.168.2.120", 6382);
        // 主机赋值
        jedisM.set("key_m", "val-m");
        // 从机获取值
        System.out.println(jedisS.get("key_m"));
        jedisM.close();
        jedisS.close();
    }
}
